package org.lql.algo.codecrush.hot100.skill;

/**
 * @author: liangqinglong
 * @date: 2025-10-13 23:20
 * @description: 136. 只出现一次的数字 <a href="https://leetcode.cn/problems/single-number/description/?envType=study-plan-v2&envId=top-100-liked">...</a>
 **/
public class SingleNumber {

	public int singleNumber(int[] nums) {
		int ans = 0;
		for (int num : nums) {
			ans ^= num;
		}
		return ans;
	}

	public static void main(String[] args) {
		System.out.println(new SingleNumber().singleNumber(new int[]{2, 2, 1}));
		System.out.println(new SingleNumber().singleNumber(new int[]{4, 1, 2, 1, 2}));
		System.out.println(new SingleNumber().singleNumber(new int[]{1}));
	}
}
